<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../plugins/layui/css/layui.css?v=${.Config.basic.version}" media="all">
    <link rel="stylesheet" href="../plugins/layui/css/style.css?v=${.Config.basic.version}" media="all">
    <link rel="stylesheet" href="../layuiadmin/style/admin.css?v=${.Config.basic.version}" media="all">
    <style>
        .layui-form-label {
            width: 50px;
        }
        .layui-form-item .layui-input-inline {
            float: left;
            width: 150px;
            margin-right: 10px;
        }
        .layui-form-item {
            margin-top: 5px;
            margin-bottom: 10px;
        }
    </style>
    <style>
        /* .layui-table-view .layui-table td, .layui-table-view .layui-table th {
            padding: 5px 0;
            border-top: 1px solid #404453;
            border-left: 1px solid #404453;
            border-bottom: 1px solid #404453;
            border-right: 1px solid #404453;
        } */
    </style>

</head>
<body>
<div class="">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form" action="">
                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label class="layui-form-label auto-size-label">起始</label>
                        <div class="layui-input-inline">
                            <input type="text" lay-verify="" id="txt_begin"  name="txt_begin" lay-verify="" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label auto-size-label">截止</label>
                        <div class="layui-input-inline">
                            <input type="text" lay-verify="" id="txt_end"  name="txt_end" lay-verify="" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="" lay-filter="btn_search"><i class="layui-icon layui-icon-search"></i>查询</button>
                        </div>
                    </div>

                </div>
            </form>
            <table class="layui-hide" id="table" lay-filter="table"></table>
        </div>
    </div>
</div>



<script type="text/html" id="user_table_toolbar">
    <div class="layui-btn-container">

    </div>
</script>



<script src="../plugins/layui/layui.js"></script>
<script src="../plugins/jquery/jquery-3.6.0.js?v=${.Config.basic.version}"></script>
<script>
    var table=null;
    var form=null;
    var Table=null;
    var token = window.localStorage.getItem("token");
    var user_info=JSON.parse(window.localStorage.getItem("user_info"));
    var func_url="${.func_url}";
    var actions=[];
    var token = window.localStorage.getItem("token");
    token = 'Bearer ' + token;
    layui.config({
        base: '../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table','form','laydate'], function(){
        $ = layui.$;
        form = layui.form;
        table = layui.table;
        laydate=layui.laydate;

        $.ajax({
            type: 'GET',
            url: '../Api/User/Actions',
            data: {func_url:func_url},
            beforeSend: function(request) {
                request.setRequestHeader("Authorization", 'Bearer '+window.localStorage.getItem("token"));
            },
            dataType: "json",
            success: function (data) {
                console.info(data)
                actions=data.data;
                for(var i=0;i<actions.length;i++){
                    $('.action-'+actions[i].action_id).removeClass("layui-hide");
                }
                //initTable();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                layer.msg('加载操作信息失败');
            }
        });

        laydate.render({
            elem: '#txt_begin'
            ,trigger: 'click'
            ,type: 'datetime'
            ,theme: '#133678'
            //,value: begin
        });
        laydate.render({
            elem: '#txt_end'
            ,trigger: 'click'
            ,type: 'datetime'
            ,theme: '#133678'
            //,value: end
        });

        //监听提交
        form.on('submit(btn_search)', function(data){
            //layer.alert(JSON.stringify(data.field), {title: '最终的提交信息'})
            begin=data.field.txt_begin;
            end=data.field.txt_end;
            search({begin:begin,end:end});
            return false;
        });

        Table = table.render({
            elem: '#table'
            //,data:data
            ,url: '../Api/Log/LoginLog/'
            ,height: 'full-90'
            ,method:'GET'
            ,headers : {'Authorization': 'Bearer '+window.localStorage.getItem("token")}
            ,where: {order:" `log_time` desc "}
            //,page: true
            ,page: {
                limit:50,
                limits:[10, 20, 30, 40, 50,100,200,300,400],
                theme: '#3c7cff'
            }
            //,limit:30
            ,size: 'sm' //小尺寸的表格
            ,title: '登录日志'
            ,even:true
            ,cols: [[
                {field:'id', title:'id',hide:true}
                ,{field:'userid', title:'账号',width:130,sort: false}
                ,{field:'name', title:'昵称',width:80,sort: false}
                ,{field:'farmname', title:'场区',width:130,sort: false}
                ,{field:'type', title:'状态',width:60, sort: false,align:'center',templet: function(d){
                        return d.type===1?"<i class=\"layui-icon layui-icon-auz layui-text-blue \"></i>":"<i class=\"layui-icon layui-icon-close-fill layui-text-red \"></i>";
                    }}
                
                ,{field:'ip', title:'IP',width:130,sort: false}
                ,{field:'agent', title:'客户端', sort: false}
                ,{field:'log_time', title:'操作时间',width:180, sort: true,align:'left'}
                ,{field:'remark', title:'备注',width:250, sort: false}
            ]],done: function(res, curr, count){
                var that = this.elem.next();
                res.data.forEach(function (item, index) {
                    //console.log(item.empName);item表示每列显示的数据
                    
                });

            }
        });
        table.on('sort(table)', function(obj){

            table.reload('table', {
                initSort: obj //记录初始排序，如果不设的话，将无法标记表头的排序状态。
                ,where: { //请求参数（注意：这里面的参数可任意定义，并非下面固定的格式）
                    //order_field: obj.field //排序字段
                    //,order_type: obj.type //排序方式
                    order:obj.field+" "+(obj.type||"")
                }
            });
        });
    });

    function search(params) {
        Table.reload({
            where: params
            ,page: {
                curr: 1 //重新从第 1 页开始
            }
        });
    }


</script>
<script src="../js/check_screen.js?v=${.Config.basic.version}"></script>

</body>
</html>